home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gas_251.zip / bin_251 / bfd / libecoff.h < prev    next >
C/C++ Source or Header  |  1994-10-21  |  12KB  |  305 lines

  1. /* BFD ECOFF object file private structure.
  2.    Copyright (C) 1993 Free Software Foundation, Inc.
  3.    Written by Ian Lance Taylor, Cygnus Support.
  4.  
  5. This file is part of BFD, the Binary File Descriptor library.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #include "bfdlink.h"
  22.  
  23. #ifndef ECOFF_H
  24. #include "coff/ecoff.h"
  25. #endif
  26.  
  27. /* This is the backend information kept for ECOFF files.  This
  28.    structure is constant for a particular backend.  The first element
  29.    is the COFF backend data structure, so that ECOFF targets can use
  30.    the generic COFF code.  */
  31.  
  32. #define ecoff_backend(abfd) \
  33.   ((struct ecoff_backend_data *) (abfd)->xvec->backend_data)
  34.  
  35. struct ecoff_backend_data
  36. {
  37.   /* COFF backend information.  This must be the first field.  */
  38.   bfd_coff_backend_data coff;
  39.   /* Supported architecture.  */
  40.   enum bfd_architecture arch;
  41.   /* Initial portion of armap string.  */
  42.   const char *armap_start;
  43.   /* The page boundary used to align sections in a demand-paged
  44.      executable file.  E.g., 0x1000.  */
  45.   bfd_vma round;
  46.   /* True if the .rdata section is part of the text segment, as on the
  47.      Alpha.  False if .rdata is part of the data segment, as on the
  48.      MIPS.  */
  49.   boolean rdata_in_text;
  50.   /* Bitsize of constructor entries.  */
  51.   unsigned int constructor_bitsize;
  52.   /* Reloc to use for constructor entries.  */
  53.   CONST struct reloc_howto_struct *constructor_reloc;
  54.   /* How to swap debugging information.  */
  55.   struct ecoff_debug_swap debug_swap;
  56.   /* External reloc size.  */
  57.   bfd_size_type external_reloc_size;
  58.   /* Reloc swapping functions.  */
  59.   void (*swap_reloc_in) PARAMS ((bfd *, PTR, struct internal_reloc *));
  60.   void (*swap_reloc_out) PARAMS ((bfd *, const struct internal_reloc *, PTR));
  61.   /* Backend reloc tweaking.  */
  62.   void (*adjust_reloc_in) PARAMS ((bfd *, const struct internal_reloc *,
  63.                    arelent *));
  64.   void (*adjust_reloc_out) PARAMS ((bfd *, const arelent *,
  65.                     struct internal_reloc *));
  66.   /* Relocate section contents while linking.  */
  67.   boolean (*relocate_section) PARAMS ((bfd *output_bfd, struct bfd_link_info *,
  68.                        bfd *input_bfd, asection *input_section,
  69.                        bfd_byte *contents,
  70.                        PTR external_relocs));
  71. };
  72.  
  73. /* This is the target specific information kept for ECOFF files.  */
  74.  
  75. #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data)
  76.  
  77. typedef struct ecoff_tdata
  78. {
  79.   /* The reloc file position, set by
  80.      ecoff_compute_section_file_positions.  */
  81.   file_ptr reloc_filepos;
  82.  
  83.   /* The symbol table file position, set by _bfd_ecoff_mkobject_hook.  */
  84.   file_ptr sym_filepos;
  85.  
  86.   /* The start and end of the text segment.  Only valid for an
  87.      existing file, not for one we are creating.  */
  88.   unsigned long text_start;
  89.   unsigned long text_end;
  90.  
  91.   /* The cached gp value.  This is used when relocating.  */
  92.   bfd_vma gp;
  93.  
  94.   /* The maximum size of objects to optimize using gp.  This is
  95.      typically set by the -G option to the compiler, assembler or
  96.      linker.  */
  97.   int gp_size;
  98.  
  99.   /* The register masks.  When linking, all the masks found in the
  100.      input files are combined into the masks of the output file.
  101.      These are not all used for all targets, but that's OK, because
  102.      the relevant ones are the only ones swapped in and out.  */
  103.   unsigned long gprmask;
  104.   unsigned long fprmask;
  105.   unsigned long cprmask[4];
  106.  
  107.   /* The ECOFF symbolic debugging information.  */
  108.   struct ecoff_debug_info debug_info;
  109.  
  110.   /* The unswapped ECOFF symbolic information.  */
  111.   PTR raw_syments;
  112.  
  113.   /* The canonical BFD symbols.  */
  114.   struct ecoff_symbol_struct *canonical_symbols;
  115.  
  116.   /* A mapping from external symbol numbers to entries in the linker
  117.      hash table, used when linking.  */
  118.   struct ecoff_link_hash_entry **sym_hashes;
  119.  
  120.   /* A mapping from reloc symbol indices to sections, used when
  121.      linking.  */
  122.   asection **symndx_to_section;
  123.  
  124.   /* True if this BFD was written by the backend linker.  */
  125.   boolean linker;
  126.  
  127.   /* This buffers is used by the find_nearest_line entry point.  */
  128.   char *find_buffer;
  129.  
  130. } ecoff_data_type;
  131.  
  132. /* Each canonical asymbol really looks like this.  */
  133.  
  134. typedef struct ecoff_symbol_struct
  135. {
  136.   /* The actual symbol which the rest of BFD works with */
  137.   asymbol symbol;
  138.  
  139.   /* The fdr for this symbol.  */
  140.   FDR *fdr;
  141.  
  142.   /* true if this is a local symbol rather than an external one.  */
  143.   boolean local;
  144.  
  145.   /* A pointer to the unswapped hidden information for this symbol.
  146.      This is either a struct sym_ext or a struct ext_ext, depending on
  147.      the value of the local field above.  */
  148.   PTR native;
  149. } ecoff_symbol_type;
  150.  
  151. /* We take the address of the first element of a asymbol to ensure that the
  152.    macro is only ever applied to an asymbol.  */
  153. #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd)))
  154.  
  155. /* This is a hack borrowed from coffcode.h; we need to save the index
  156.    of an external symbol when we write it out so that can set the
  157.    symbol index correctly when we write out the relocs.  */
  158. #define ecoff_get_sym_index(symbol) ((unsigned long) (symbol)->udata)
  159. #define ecoff_set_sym_index(symbol, idx) ((symbol)->udata = (PTR) (idx))
  160.  
  161. /* When generating MIPS embedded PIC code, the linker relaxes the code
  162.    to turn PC relative branches into longer code sequences when the PC
  163.    relative branch is out of range.  This involves reading the relocs
  164.    in bfd_relax_section as well as in bfd_final_link, and requires the
  165.    code to keep track of which relocs have been expanded.  A pointer
  166.    to this structure is put in the used_by_bfd pointer of a section to
  167.    keep track of this information.  The user_by_bfd pointer will be
  168.    NULL if the information was not needed.  */
  169.  
  170. struct ecoff_section_tdata
  171. {
  172.   /* The unswapped relocs for this section.  These are stored in
  173.      memory so the input file does not have to be read twice.  */
  174.   PTR external_relocs;
  175.  
  176.   /* The contents of the section.  These bytes may or may not be saved
  177.      in memory, but if it is this is a pointer to them.  */
  178.   bfd_byte *contents;
  179.  
  180.   /* Offset adjustments for PC relative branches.  A number other than
  181.      1 is an addend for a PC relative branch, or a switch table entry
  182.      which is the difference of two .text locations; this addend
  183.      arises because the branch or difference crosses one or more
  184.      branches which were expanded into a larger code sequence.  A 1
  185.      means that this branch was itself expanded into a larger code
  186.      sequence.  1 is not a possible offset, since all offsets must be
  187.      multiples of the instruction size, which is 4; also, the only
  188.      relocs with non-zero offsets will be PC relative branches or
  189.      switch table entries within the same object file.  If this field
  190.      is NULL, no branches were expanded and no offsets are required.
  191.      Otherwise there are as many entries as there are relocs in the
  192.      section, and the entry for any reloc that is not PC relative is
  193.      zero.  */
  194.   long *offsets;
  195. };
  196.  
  197. /* An accessor macro for the ecoff_section_tdata structure.  */
  198. #define ecoff_section_data(abfd, sec) \
  199.   ((struct ecoff_section_tdata *) (sec)->used_by_bfd)
  200.  
  201. /* ECOFF linker hash table entries.  */
  202.  
  203. struct ecoff_link_hash_entry
  204. {
  205.   struct bfd_link_hash_entry root;
  206.   /* Symbol index in output file.  */
  207.   long indx;
  208.   /* BFD that ext field value came from.  */
  209.   bfd *abfd;
  210.   /* ECOFF external symbol information.  */
  211.   EXTR esym;
  212.   /* Nonzero if this symbol has been written out.  */
  213.   char written;
  214.   /* Nonzero if this symbol was referred to as small undefined.  */
  215.   char small;
  216. };
  217.  
  218. /* ECOFF linker hash table.  */
  219.  
  220. struct ecoff_link_hash_table
  221. {
  222.   struct bfd_link_hash_table root;
  223. };
  224.  
  225. /* Make an ECOFF object.  */
  226. extern boolean _bfd_ecoff_mkobject PARAMS ((bfd *));
  227.  
  228. /* Read in the ECOFF symbolic debugging information.  */
  229. extern boolean _bfd_ecoff_slurp_symbolic_info
  230.   PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
  231.  
  232. /* Generic ECOFF BFD backend vectors.  */
  233.  
  234. extern boolean _bfd_ecoff_write_object_contents PARAMS ((bfd *abfd));
  235. extern const bfd_target *_bfd_ecoff_archive_p PARAMS ((bfd *abfd));
  236.  
  237. #define    _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
  238. #define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
  239. extern boolean _bfd_ecoff_new_section_hook
  240.   PARAMS ((bfd *, asection *));
  241. extern boolean _bfd_ecoff_get_section_contents
  242.   PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
  243.  
  244. extern boolean _bfd_ecoff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
  245. #define _bfd_ecoff_bfd_copy_private_section_data \
  246.   _bfd_generic_bfd_copy_private_section_data
  247.  
  248. extern boolean _bfd_ecoff_slurp_armap PARAMS ((bfd *abfd));
  249. #define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table
  250. #define _bfd_ecoff_construct_extended_name_table \
  251.   _bfd_archive_bsd_construct_extended_name_table
  252. #define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname
  253. extern boolean _bfd_ecoff_write_armap
  254.   PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
  255. #define _bfd_ecoff_openr_next_archived_file \
  256.   bfd_generic_openr_next_archived_file
  257. #define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt
  258. #define _bfd_ecoff_update_armap_timestamp bfd_true
  259.  
  260. extern long _bfd_ecoff_get_symtab_upper_bound PARAMS ((bfd *abfd));
  261. extern long _bfd_ecoff_get_symtab PARAMS ((bfd *abfd, asymbol **alocation));
  262. extern asymbol *_bfd_ecoff_make_empty_symbol PARAMS ((bfd *abfd));
  263. extern void _bfd_ecoff_print_symbol
  264.   PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type));
  265. extern void _bfd_ecoff_get_symbol_info
  266.   PARAMS ((bfd *, asymbol *, symbol_info *));
  267. #define _bfd_ecoff_bfd_is_local_label bfd_generic_is_local_label
  268. #define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno
  269. extern boolean _bfd_ecoff_find_nearest_line
  270.   PARAMS ((bfd *, asection *, asymbol **, bfd_vma offset,
  271.        const char **filename_ptr, const char **fnname_ptr,
  272.        unsigned int *retline_ptr));
  273. #define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
  274.  
  275. #define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound
  276. extern long _bfd_ecoff_canonicalize_reloc
  277.   PARAMS ((bfd *, asection *, arelent **, asymbol **symbols));
  278. /* ecoff_bfd_reloc_type_lookup defined by backend. */
  279.  
  280. extern boolean _bfd_ecoff_set_arch_mach
  281.   PARAMS ((bfd *, enum bfd_architecture, unsigned long machine));
  282. extern boolean _bfd_ecoff_set_section_contents
  283.   PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
  284.  
  285. extern int _bfd_ecoff_sizeof_headers PARAMS ((bfd *abfd, boolean reloc));
  286. /* ecoff_bfd_get_relocated_section_contents defined by backend.  */
  287. /* ecoff_bfd_relax_section defined by backend.  */
  288. extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create
  289.   PARAMS ((bfd *));
  290. extern boolean _bfd_ecoff_bfd_link_add_symbols
  291.   PARAMS ((bfd *, struct bfd_link_info *));
  292. extern boolean _bfd_ecoff_bfd_final_link
  293.   PARAMS ((bfd *, struct bfd_link_info *));
  294.  
  295. /* Hook functions for the generic COFF section reading code.  */
  296.  
  297. extern PTR _bfd_ecoff_mkobject_hook PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
  298. extern asection *_bfd_ecoff_make_section_hook PARAMS ((bfd *abfd, char *name));
  299. #define _bfd_ecoff_set_alignment_hook \
  300.   ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
  301. extern boolean _bfd_ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
  302. extern flagword _bfd_ecoff_styp_to_sec_flags
  303.   PARAMS ((bfd *abfd, PTR hdr, const char *name));
  304. extern boolean _bfd_ecoff_slurp_symbol_table PARAMS ((bfd *abfd));
  305.